import {createApp} from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'ant-design-vue/dist/antd.css'
import antd from 'ant-design-vue';
import {message} from 'ant-design-vue';
import axios from 'axios'


createApp(App).use(store).use(antd).use(router).mount('#app')

axios.defaults.withCredentials = true;
axios.defaults.baseURL = "http://localhost:8081"

// Add a request interceptor
axios.interceptors.request.use(function (config) {
    // Do something before request is sent
    console.log("发送请求", config.url)

    return config;
}, function (error) {
    // Do something with request error
    return Promise.reject(error);
});

// Add a response interceptor
axios.interceptors.response.use(function (response) {
    console.log("请求返回值", response)
    if (response.data.code == 5001) {
        message.error(response.data.message)
        router.push('/')
    }
    return response;
}, function (error) {
    // Any status codes that falls outside the range of 2xx cause this function to trigger
    // Do something with response error
    return Promise.reject(error);
});

